<template>
	<view v-if="isLoggedIn">
		<slot/>
	</view>
	<view v-else class="center">
		<button @tap="goLogin" class="login-btn">登录</button>
	</view>
	
</template>

<script setup lang="ts">
	import { computed } from 'vue';
import { LAN_URL } from '../config/global';
	
	//检查是否已登录
	const isLoggedIn = computed(()=>{
		const user = uni.getStorageSync('user')
		console.log("用户信息"+user)
		if(user==null || user==""){
			return false;
		}
		return true
	})
	
	const goLogin = () =>{
		uni.navigateTo({
			url:'/pages/login/login'
		})
	}
</script>

<style>
	.center{
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.login-btn{
		width: 80%;
		height: 80rpx;
		margin: 30rpx 0;
		background: #007AFF;
		color: white;
		border-radius: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>